#filename:getdatatolocal.py
#coding: utf-8
import urllib2
from bs4 import BeautifulSoup

#解决编码问题 UnicodeEncodeError: 'ascii'---'utf-8'
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )

url = 'http://adamee.duapp.com/'
require = urllib2.Request(url)
html = urllib2.urlopen( require )
soup = BeautifulSoup(html.read())
wr = open("data.txt", 'w')
for link in soup.find_all('a',attrs={'class':'btn'}):
        wr.write('title='+link.get_text()+'\t'+'href='+link.get('href')+'\n')
wr.close()
